<template>
  <ElDrawer v-model="visible">
    <ElDescriptions :span="2">
      <ElDescriptionsItem label="贷款银行">{{ bankMaterial.bankCode }}</ElDescriptionsItem>
      <ElDescriptionsItem label="标题">{{ bankMaterial.title }}</ElDescriptionsItem>
      <ElDescriptionsItem label="利率">{{ bankMaterial.rate }}</ElDescriptionsItem>
      <ElDescriptionsItem label="贷款年限">{{ bankMaterial.period }}</ElDescriptionsItem>
      <ElDescriptionsItem label="单位">{{ bankMaterial.unit }}</ElDescriptionsItem>
    </ElDescriptions>
    <ElForm>
      <ElFormItem label="贷款金额">
        <ElInputNumber v-model="loanBill.applyAmount" :step="1000"></ElInputNumber>
      </ElFormItem>
      <ElFormItem label="营业执照上传">
        <ElInput v-model="loanBill.bizLicense" ></ElInput>
      </ElFormItem>
      <ElFormItem label="对公银行卡上传">
        <ElInput v-model="loanBill.bizCard" ></ElInput>
      </ElFormItem>
      <ElFormItem>
        <ElButton type="primary" @click="insert()">申请贷款</ElButton>
      </ElFormItem>
    </ElForm>
  </ElDrawer>
</template>
<script lang="ts" setup>
const emit = defineEmits([])
const router = useRouter()
const visible = ref(false)
const bankMaterial: any = reactive({})
const loanBill = reactive({
  materialCode: '',
  loanBank: '',
  applyAmount: 10000,

  loanCode: '',
  billState: 'toSubmit',
  loanApplier: '',
  firstAuditTime: null,
  firstAuditWord: null,
  secondAuditTime: null,
  secondAuditWord: null,
  version: 0,
  updateTime: null,
  firstAuditor: null,
  bizCard: '',
  bizLicense: ''
})
const show = (data: any) => {
  Object.assign(bankMaterial, data)
  visible.value = true
  loanBill.loanBank = bankMaterial.bankCode
  loanBill.materialCode = bankMaterial.materialCode
}
defineExpose({ show })
const insert = async () => {
 const res = await  axios({
    method: 'post',
    url: 'http://localhost:9091/loanBill/insert',
    data: loanBill
  })
 visible.value=false
 router.push("/loanApplierHistory")
}
</script>
<style lang="scss" scoped></style>
